﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MMPS.Business;
using MMPS.Entity.ViewModel;
using MMPS.Common;
using System.Linq.Expressions;

namespace MMPS.Controllers
{
    public class UserInfoController : Controller
    {
        //实例化
        UserServe UserServe = new UserServe();
        // GET: UserInfo
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult GetListUserInfo(UserPageViewModel viewModel)
        {
            var dataLiat = UserServe.GetUserList(viewModel);
            //返回Json数据
            return Json(dataLiat.Data);
        }
        public ActionResult add()
        {

            //绑定用户角色下拉框
            var role = EnumHelper.EnumListDic<RoleTypeEnum>("请选择","0");
            var roleList = new SelectList(role,"value","key");
            return View();
        }
        [HttpPost]
        public ActionResult add(UserListViewModel viewModel)
        {
          OperateResult result=UserServe.UserADD(viewModel);
            return Json(result);
        }
        public ActionResult Edit(int id)
        {
            var dataList = UserServe.UserListUpdate(id);
            return View("add", dataList.Data);
        }
        [HttpPost]
        public ActionResult Edit(UserListViewModel viewModel)
        {
            OperateResult result = UserServe.UserUpdate(viewModel);
            return Json(result);
        }
        [HttpPost]
        public ActionResult Delete(UserPageViewModel viewModel)
        {
            //UserPageViewModel viewModel = new UserPageViewModel();
            //viewModel.U_ID = U_ID;
            OperateResult result = UserServe.UserDelete(viewModel);
            return Json(result);
        }




    }
}